package managedbean;


import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;
import java.util.*;

import javax.ejb.EJB;
import javax.faces.bean.*;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.naming.Context;
import javax.naming.InitialContext;

import jpa.CustomerJPA;
import jpa.OrderJPA;
import jpa.OrderdetailJPA;
import jpa.PetJPA;
import jpa.ShippingAddressJPA;
import ejb.CatalogFacadeRemote;
import ejb.OrderFacadeRemote;
import jpa.ShoppingCart;

/**
 * Managed Bean TotalAmountByCustomerMBean
 */
@ManagedBean(name = "testOrder")
@SessionScoped
public class TestOrder implements Serializable {

	private static final long serialVersionUID = 1L;
	private CustomerJPA customer;
	private ShoppingCart shoppingCart;
		
	public TestOrder() {
		super();
	}	
	
	@SuppressWarnings("unchecked")
	public String NewOrder() throws Exception {
		//Creacio ShoopingCart per poder testejar la funcionalitat
		shoppingCart =new ShoppingCart();
		ShowtPetMBean sp = new ShowtPetMBean();
		sp.setIdPet(2);
		shoppingCart.getPets().add(sp.getDataPet());
		//Client al que es creara la comanda, caldra sustituir aquesta part pel dni de l'usuari connectat
		//customer=(CustomerJPA)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("loginController");
		ShowClientMBean sc = new ShowClientMBean("34567890n");
		customer=sc.getDataCustomer();
		NewOrderMBean no= new NewOrderMBean(shoppingCart,customer.getShippingAddress());
		return "NewOrderView";	
	}

	
	public ShoppingCart getShoppingCart() {
		return shoppingCart;
	}

	public CustomerJPA getCustomer() {
		return customer;
	}

	
}